// pages/killPrice/lists.js
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentPage: 1,
    data: [],
    ready: 2
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.loadData();
  },
  loadData: function() {
    var that = this;
    utils.http("/api/v1/bargaingoods/my_bargain_order", {
      page: that.data.currentPage
    }, function(res) {
      if (res.state == 1) {
        that.setData({
          data: that.data.data.concat(res.datas),
          ready: res.datas.length == 0 ? 1 : 2,
        });
      } else {
        wx.showToast({
          title: res.datas,
          icon: 'none'
        });
      }
      utils.hideLoading();
    })
  },
  details: function(e) {
    var id = e.currentTarget.dataset.id;
    console.log(id)
    wx.navigateTo({
      url: '/pages/killPrice/details?id=' + id,
    })
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  onReachBottom: function() {
    var that = this;
    if (that.data.ready == 2) {
      var page = that.data.currentPage + 1
      that.setData({
        currentPage: page,
      }, function() {
        that.loadData()
      })
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})